package test.springtheorem;

/**
 * @Description: 带有注解的服务; 3种注入方式都可以;
 * @ClassName: UserDaoImpl
 */
public class UserServiceImpl {

    public UserDaoImpl userDao;
    public User1DaoImpl user1Dao;

    // 字段上的注解,可以配置name属性(因为有xml的beanId保底,所以这里name为空也照样完成注入)
    @Resource
    public User2DaoImpl user2Dao;

    // set方法上的注解，带有name属性  
    @Resource(name = "userDao")
    public void setUserDao(UserDaoImpl userDao) {
        this.userDao = userDao;
    }

    // set方法上的注解，没有配置name属性  
    @Resource
    public void setUser1Dao(User1DaoImpl user1Dao) {
        this.user1Dao = user1Dao;
    }

    public void show() {
        userDao.show();
        user1Dao.show1();
        user2Dao.show2();
        System.out.println("这里是Service方法........");
    }
}  